/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.onlyxiahui.framework.net.session.server;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * Date 2018-12-30 10:36:22<br>
 * Description 消息载体
 *
 * @author XiaHui<br>
 * @since 1.0.0
 */
public class DataItem {

    /**
     * 消息推送的类型
     */
    private Type type;
    /**
     * 消息需要推送的session的key
     */
    private List<String> keyList;
    /**
     * 消息体
     */
    private Object data;

    public DataItem() {
    }

    public DataItem(Type type, String key, Object data) {
        this.type = type;
        this.keyList = new ArrayList<>();
        this.data = data;
        keyList.add(key);
    }

    public DataItem(Type type, List<String> keyList, Object data) {
        this.type = type;
        this.keyList = keyList;
        this.data = data;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public List<String> getKeyList() {
        return keyList;
    }

    public void setKeyList(List<String> keyList) {
        this.keyList = keyList;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public enum Type {
        /**
         * 消息只推送给一个
         */
        one,
        /**
         * 消息推送给整个列表
         */
        list,
        /**
         * 消息推送排除列表中的
         */
        without,
        /**
         * 消息推送给所有
         */
        all;
    }
}
